package lab02.test13;

public  class Gymnastics extends ComputerAverage {
    double math;
    double PE;
    double computer;
    double english;
    double ps;

    @Override
    public double average() {
        double [] a={math,PE,computer,english,ps};
            double max;
            double min;
            min=max=a[0];
            int k1=0,k2=0;

            for (int i=0;i<a.length;i++){
                if (a[i]>max){
                    max=a[i];
                    k1=i;
                }else if (a[i]<min){
                    min=a[i];
                    k2=i;
                }
            }
            a[k1]=0;
            a[k2]=0;
            double sum=0;

            for (int i=0;i<a.length;i++){
                sum=sum+a[i];
            }

            sum=sum/(a.length-2);
            return  sum;
    }
}
